package com.walk.zworld.mvvm.vm

import androidx.lifecycle.LiveData
import com.walk.zworld.mvvm.repository.QuestionRepository
import com.base.lib.httpUtils.ArticleListBean
import com.base.lib.base.event.SingleLiveEvent
import com.base.lib.base.mvvm.viewmodel.BaseRefreshViewModel
import com.base.lib.httpUtils.Article

class QuestionViewModel : BaseRefreshViewModel<Article>() {

    private val repository = QuestionRepository()
    private val questionData = SingleLiveEvent<ArticleListBean>()

    fun getQuestionList(page: Int): LiveData<ArticleListBean> {
        launchUI {
            val result = repository.getQuestionList(page)
            questionData.value = result.data!!
            mData.value = result.data.datas
        }
        return questionData
    }

    override fun refreshData(params: Any?) {
        page = 0;
        getQuestionList(page)
    }

    override fun loadMore(params: Any?) {
        page += 1;
        getQuestionList(page)
    }

}